


# 写一个面向对象的例子：
# 比如创建一个类（Animal）【动物类】，
# 类里有属性（名称，颜色，年龄，性别），
# 类方法（会叫，会跑）
class Animal:
    name = ''
    color = ''
    age = ''
    sex = ''
    def __init__(self,name,color,age,sex):
        self.name=name
        self.color=color
        self.age=age
        self.sex=sex
    def speak(self):
        print("会叫")
    def run(self):
        print(f"{self.name}会跑")
class Cat(Animal):
    def __init__(self,name,color,age,sex):
        super(Cat, self).__init__(name,color,age,sex)
        self.fur="短毛"
    def cat_mouse(self):
        print(f"{self.name}会抓老鼠")
    def speak(self):
        print("小猫喵喵叫")
class Dog(Animal):
    def __init__(self,name,color,age,sex):
        super(Dog, self).__init__(name,color,age,sex)
        self.fur="长毛"
    def catch_house(self):
        print(f"{self.name}会看家")
    def speak(self):
        print("小狗汪汪叫")
if __name__ == '__main__':
    cat = Cat("小白","波斯",15,"公的")
    cat.cat_mouse()
    print(cat.name,cat.color,cat.age,cat.sex,"捉到了老鼠")
    print(f"姓名为：{cat.name},颜色为:{cat.color},年龄为：{cat.age},性别为：{cat.sex}")
